//
//  WJCommonUtils+prefs.m
//  verycloud
//
//  Created by 王军 on 2017/3/7.
//  Copyright © 2017年 王军. All rights reserved.
//
/***

 ***/

#import "WJCommonUtils+prefs.h"
#import <AVFoundation/AVFoundation.h>
#import "WJAlertUtils.h"

@implementation WJCommonUtils (prefs)

+(void)openPrefs:(NSString *)str{
//    if([str isEqualToString:@"Prefs:root=WIFI"]){
//        NSURL *url = [NSURL URLWithString:str];
//        if ([[UIApplication sharedApplication] canOpenURL:url]) {
//            // 系统小于10的时候，打开Wi-Fi界面
//            [[UIApplication sharedApplication] openURL:url];
//        } else {
//            // 系统大于10的时候直接打开当前App的设置界面
//            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
//        }
//        return;
//    }
//    NSURL *url = [NSURL URLWithString:str];
//    [[UIApplication sharedApplication] openURL:url];
}

//wifi
+(void)openWifi{
//    [WJCommonUtils openPrefs:@"Prefs:root=WIFI"];
}

//电池电量
+(void)openBATTERY{
//    [WJCommonUtils openPrefs:@"Prefs:root=BATTERY_USAGE"];
}
//通用设置
+(void)openGeneral{
//    [WJCommonUtils openPrefs:@"Prefs:root=General"];
}
//定位设置
+(void)openLOCATION{
//    [WJCommonUtils openPrefs:@"Prefs:root=Privacy&path=LOCATION"];
}

+(BOOL)checkCameraPermiAlert{
    BOOL bo = [WJCommonUtils checkCameraPermi];
    if(!bo){
         [WJAlertUtils alertMsg:@"请在iPhone的“设置-隐私-相册”选项中，允许访问你的相机" vc:nil];
    }
    return bo;
}

//检查相机权限
+(BOOL)checkCameraPermi{
    NSString * mediaType = AVMediaTypeVideo;
    AVAuthorizationStatus  authorizationStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
    if (authorizationStatus == AVAuthorizationStatusRestricted|| authorizationStatus == AVAuthorizationStatusDenied) {
        return NO;
    }else{
        return YES;
    }
}


@end
